﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Rob Ashton 2009
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@mvcex.com
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Xml.Serialization;
using System.IO;
using MvcEx.Configuration;

namespace MvcEx.Tests
{
    [TestFixture]
    public class MvcExConfigurationTests
    {
        [Test]
        public void deserialise_configuration_and_verify_properties()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(MvcExConfiguration));
            MvcExConfiguration config = null;
            using (var stream = new FileStream("data/MvcExConfigurationTests/TestConfiguration.xml", FileMode.Open, FileAccess.Read))
            {
                config = (MvcExConfiguration)serializer.Deserialize(stream);
            }

            Assert.NotNull(config);
            Assert.AreEqual("TestConfiguration", config.DisplayName);
            Assert.NotNull(config.Modules);
            Assert.AreEqual(2, config.Modules.Length);
            Assert.AreEqual("test1", config.Modules[0].Name);
            Assert.AreEqual("test2", config.Modules[1].Name);
        }
    }
}
